package com.overseasShopping.Action;

import java.util.List;
import java.util.Map;

import com.opensymphony.xwork2.ActionContext;
import com.overseasShopping.Biz.OrderListBiz;
import com.overseasShopping.pojo.OrderList;
import com.overseasShopping.pojo.User;

public class TransactionAction {
	private String buyUserId;
	private String saleUserId;
	private int state;
	public void setState(int state) {
		this.state = state;
	}

	private OrderListBiz orderListBiz;
	
	public OrderListBiz getOrderListBiz() {
		return orderListBiz;
	}
	public void setOrderListBiz(OrderListBiz orderListBiz) {
		this.orderListBiz = orderListBiz;
	}
	public void setBuyUserId(String buyUserId) {
		this.buyUserId = buyUserId;
	}
	public void setSaleUserId(String saleUserId) {
		this.saleUserId = saleUserId;
	}
	//获取用户
	private User getUser(){
		Map<String, Object>map=ActionContext.getContext().getSession();
		User user=(User) map.get("user");
		return user;

		
	}
	
	
	public String getAll(){
		String buyUserId=getUser().getUserId();
		saleUserId=buyUserId;
		//根据ID获取所有订单
		List<OrderList> orderListAll = orderListBiz.getUserIdAll(buyUserId, saleUserId);
		ActionContext.getContext().getSession().put("orderListAll", orderListAll);
		
		//获取买家订单
		List<OrderList> orderBuyLists = orderListBiz.getBuyUserIdAll(buyUserId);
		ActionContext.getContext().getSession().put("orderBuyLists", orderBuyLists);
		//获取卖家订单
		List<OrderList> orderSaleLists = orderListBiz.getSaleUserIdAll(saleUserId);
		ActionContext.getContext().getSession().put("orderSaleLists", orderSaleLists);
		//根据状态获取订单
		state = 1;
		List<OrderList> buyStates1 = orderListBiz.getBuyStateList(state, buyUserId);
		ActionContext.getContext().getSession().put("buyStates1", buyStates1);
		
		List<OrderList> saleStates1 = orderListBiz.getSaleStateList(state, saleUserId);
		ActionContext.getContext().getSession().put("saleStates1", saleStates1);
		state = 2;
		List<OrderList> buyStates2 = orderListBiz.getBuyStateList(state, buyUserId);
		ActionContext.getContext().getSession().put("buyStates2", buyStates2);
		
		List<OrderList> saleStates2 = orderListBiz.getSaleStateList(state, saleUserId);
		ActionContext.getContext().getSession().put("saleStates2", saleStates2);
		state = 3;
		List<OrderList> buyStates3 = orderListBiz.getBuyStateList(state, buyUserId);
		ActionContext.getContext().getSession().put("buyStates3", buyStates3);
		
		List<OrderList> saleStates3 = orderListBiz.getSaleStateList(state, saleUserId);
		ActionContext.getContext().getSession().put("saleStates3", saleStates3);
		state = 4;
		List<OrderList> buyStates4 = orderListBiz.getBuyStateList(state, buyUserId);
		ActionContext.getContext().getSession().put("buyStates4", buyStates4);
		
		List<OrderList> saleStates4 = orderListBiz.getSaleStateList(state, saleUserId);
		ActionContext.getContext().getSession().put("saleStates4", saleStates4);
		
		state = 5;
		List<OrderList> saleStates5 = orderListBiz.getSaleStateList(state, saleUserId);
		ActionContext.getContext().getSession().put("saleStates5", saleStates5);

		state = 6;
		List<OrderList> buyStates6 = orderListBiz.getBuyStateList(state, buyUserId);
		ActionContext.getContext().getSession().put("buyStates6", buyStates6);
		
		return "success";
	}
	


}
